﻿using zijian666.WorkScheduler.Defines;

namespace zijian666.WorkScheduler.Abstractions;

/// <summary>
/// 工作上下文
/// </summary>
public interface IWorkContext : IDisposable
{
    /// <summary>
    /// 获取取消令牌
    /// </summary>
    CancellationToken Cancellation { get; }
    /// <summary>
    /// 获取工作数据
    /// </summary>
    WorkData Data { get; }
    /// <summary>
    /// 工作失败
    /// </summary>
    /// <param name="exception">失败原因</param>
    /// <param name="progressValue">失败后进</param>
    /// <param name="remark">备注</param>
    Task Fail(Exception exception, string? remark = null, double progressValue = 1);
    /// <summary>
    /// 上报工作进度
    /// </summary>
    /// <param name="progressValue">工作进度</param>
    /// <param name="remark">备注</param>
    Task Report(double progressValue, string? remark = null);
    /// <summary>
    /// 工作成功
    /// </summary>
    /// <param name="result">工作成果</param>
    /// <param name="remark">备注</param>
    /// <returns></returns>
    Task Success(string result, string? remark = null);
}